using System;
using Castle.MonoRail.ActiveRecordSupport;
using Castle.MonoRail.Framework;
using IronMis2.Models;

namespace IronMis2.Controllers
{
    public class CommodityController:BaseController
    {
        public void Index()
        {
            PropertyBag["commodities"] = Commodity.FindAll();
        }
        public void Edit(Guid id)
        {
            PropertyBag["commodity"] = Commodity.Find(id);
            PropertyBag["providers"] = Provider.FindAll();
            PropertyBag["storehouse"] = Storehouse.FindAll();
        }
        public void Update([DataBind("commodity")] Commodity commodity)
        {
            commodity.UpdateAndFlush();
            RedirectToAction("Index");
        }
        public void Destroy(Guid id)
        {
            Commodity.Find(id).DeleteAndFlush();
            RedirectToAction("Index");
        }
    }
}
